﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Links.aspx.cs" Inherits="Marbles.Web.Admin.Content.Links" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Favourite Browser</title>

    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <link href="/App_Themes/Admin/Site.css" type="text/css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <b>Favourites</b>
        <table border="0" cellpadding="2" cellspacing="0">
            <tr>
                <td>
                    Custom Link Url:
                </td>
                <td>
                    &nbsp;
                </td>
                <td>
                    <input type="text" id="cTxtUrl" value="" maxlength="512" width="300px" />
                </td>
                <td>
                    &nbsp;
                </td>
                <td>
                    Title:
                </td>
                <td>
                    <input type="text" id="cTxtTitle" value="" maxlength="255" width="200px" /><input
                        type="button" value="Use this Custom Link" onclick="SelectCustomLink();" />
                </td>
            </tr>
        </table>
        Or Select from a predefined Favourite below.
        <div class="scrollDiv" style="width: 610px; height: 380px; overflow: scroll;">
            <asp:DataGrid ID="cGrdFiles" runat="server" AutoGenerateColumns="false" DataKeyField="linkid"
                Width="595px" BorderColor="Black" ForeColor="Black" BorderStyle="Solid" BorderWidth="1px"
                GridLines="Both" CellPadding="2" CellSpacing="0">
                <HeaderStyle BackColor="Silver" />
                <Columns>
                    <asp:TemplateColumn HeaderText="Title">
                        <ItemTemplate>
                            <a title="Click  here to select this link." href="javascript:SelectLink('<%#Eval("ShortLinkUrl") %>','<%#Eval("title") %>');">
                                <%#Eval("title") %></a></ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="Link">
                        <ItemTemplate>
                            <a href='<%#Eval("ShortLinkUrl") %>' target="_blank" title="Click to view Destination">
                                <%#Eval("Url") %></a></ItemTemplate>
                    </asp:TemplateColumn>
                    <asp:TemplateColumn HeaderText="Description">
                        <ItemStyle Width="96%" />
                        <ItemTemplate>
                            <%#Eval("Description") %></ItemTemplate>
                    </asp:TemplateColumn>
                </Columns>
            </asp:DataGrid>
        </div>
        <br />
        <center>
            <asp:Button ID="cBtnClose" runat="server" Text="Close" OnClientClick="CloseWindow();return false;" /></center>
        <script language="javascript" type="text/javascript">
            function CloseWindow() {
                window.returnValue = '';
                window.close();
            }

            function SelectLink(url, title) {
                window.returnValue = url + '$' + title;
                window.close();
            }

            function SelectCustomLink() {
                var url = document.getElementById('cTxtUrl').value;
                var title = document.getElementById('cTxtTitle').value;
                if (url == '') {
                    alert('Custom Link Url must contain a value.');
                    return;
                }

                SelectLink(url, title);
            }
        </script>
    </form>
</body>
</html>
